package com.atzxh.io.bio.one;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;

/**
 * @author 小红同学
 * @create 2023-04-11-17:30
 * @description  客户端只发送一次消息
 */
public class Client {
    public static void main(String[] args) throws IOException {

        // 1、创建socket对象请求服务端的连接
        Socket socket = new Socket("127.0.0.1", 9999);
        // 2、从socket对象获取一个字符输出流
        OutputStream os = socket.getOutputStream();
        // 3、把字符输出流包装成一个打印流
        PrintStream ps = new PrintStream(os);
        ps.println("hello 服务端 !!!");
        ps.flush();
    }
}
